RWTH - Mindstorms NXT Toolbox

GetSound

Reads the current value of the NXT sound sensor

Contents

Syntax

sound = GetSound(port)

sound = GetSound(port, handle)

Description

sound = GetSound(port) returns the current sound value sound of the NXT sound sensor. The measurement value sound represents the normalized (default) sound value (0..1023 / 10 Bit). The normalized value mode is set per default by the function OpenSound. The given port number specifies the connection port. The value port can be addressed by the symbolic constants SENSOR_1, SENSOR_2, SENSOR_3 and SENSOR_4 analog to the labeling on the NXT Brick.

The last optional argument can be a valid NXT handle. If none is specified, the default handle will be used (call COM_SetDefaultNXT to set one).

For more complex settings the function NXT_GetInputMode can be used.

Example

   OpenSound(SENSOR_1, 'DB');
   sound = GetSound(SENSOR_1);
   CloseSensor(SENSOR_1);

See also

NXT_SetInputMode, OpenLight, CloseSensor, SENSOR_1, SENSOR_2, SENSOR_3, SENSOR_4

Signature